package be.bejug.scrumadmin.components.panels;

import com.vaadin.ui.Component;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;
import com.vaadin.ui.TabSheet.SelectedTabChangeListener;
import com.vaadin.ui.VerticalLayout;

/**
 * 
 * @author Glenn Dejaeger
 * 
 */
@SuppressWarnings("serial")
public class ContentPanel extends VerticalLayout {

	public ContentPanel() {
		TabSheet tabSheet = new TabSheet();
		tabSheet.setSizeFull();
		tabSheet.addListener(new SelectedTabChangeListener() {
			private static final long serialVersionUID = 1L;

			@Override
			public void selectedTabChange(final SelectedTabChangeEvent event) {
				Component selectedTab = event.getTabSheet().getSelectedTab();
				if ((selectedTab != null)
						&& AbstractTab.class.isAssignableFrom(selectedTab
								.getClass())) {
					((AbstractTab) selectedTab).loadData();
				}
			}
		});

		tabSheet.addTab(new BacklogPanel());
		tabSheet.addTab(new SprintListPanel());
		tabSheet.addTab(new SprintTaskPanel());
		tabSheet.addTab(new SprintGraphPanel());
		addComponent(tabSheet);
	}

}
